package busterminalweb.authorization;

import busterminal.entity.AbstractEntityImplementation;
import busterminalweb.authorization.service.Role;

/**
 *
 */
public class User extends AbstractEntityImplementation {

    private String login;
    private String password;
    private String name;
    private Role role;

    public User() {
    }

    public User(String login, String password, String name, Role role) {
        this.login = login;
        this.password = password;
        this.name = name;
        this.role = role;
    }

    public String getLogin() {
        return login;
    }

    public void setLogin(String login) {
        this.login = login;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }
    
    public static User createUser(String login, String password, String name, String role) {
        User user = new User();
        user.setLogin(login);
        user.setPassword(password);
        user.setName(name);
        user.setRole(Role.valueOf(role.toUpperCase()));
        
        return user;
    }
}
